
#include "DeviceInfo.h"
#include "android/JNIHelper.h"
#include "android/Convert_Device.h"

int32_t DeviceInfo::getCameraDeviceCount() {
  auto pEnv = JNIHelper::Instance()->getEnv();
  jclass infoClass = pEnv->FindClass("com/fan/play/media/capture/video/Camera2Info");
  jmethodID countID = pEnv->GetStaticMethodID(infoClass, "getCameraCount", "()I");
  return pEnv->CallStaticIntMethod(infoClass, countID);
}

IDevice *DeviceInfo::getCameraDevice(int32_t cameraID) {
  auto pEnv = JNIHelper::Instance()->getEnv();
  jclass infoClass = pEnv->FindClass("com/fan/play/media/capture/video/Camera2Info");
  jmethodID cameraInfoID = pEnv->GetStaticMethodID(infoClass, "getCameraInfo",
                                                   "(I)Lcom/fan/play/media/engine/CaptureDeviceCamera;");
  jobject jDevice = pEnv->CallStaticObjectMethod(infoClass, cameraInfoID, cameraID);
  Convert_Device device;
  return device.java2Object(jDevice);
}

int32_t DeviceInfo::getChannelNum() {
  auto pEnv = JNIHelper::Instance()->getEnv();
  jclass infoClass = pEnv->FindClass("com/fan/play/media/capture/audio/AudioInfo");
  jmethodID channelNumID = pEnv->GetStaticMethodID(infoClass, "getChannelNum", "()I");
  return pEnv->CallStaticIntMethod(infoClass, channelNumID);
}
